package controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import pojo.Customer;
import service.CustomerManager;

@Controller
public class CustomerController {
	@Resource(name = "customerManager")
	private CustomerManager cm;

	@RequestMapping(value = "/regist")
	public String regist(Customer c) {
		Customer c1 = cm.regist(c);
		if (c1 != null)
			return "login";
		else
			return "fail";
	}
	@RequestMapping(value = "/login")
	public String login(String cname,String psd,Model model) {
		Customer c1 = cm.login(cname, psd);
		if (c1 != null)
			return "welcome";
		else
			model.addAttribute("error", "用户名或密码错误");
			return "login";
	}

}
